﻿package mortal.game.net.command.heroArena
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import mortal.game.cache.*;
    import mortal.game.control.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.view.heroArena.util.*;
    import mortal.mvc.core.*;

    public class HeroArenaCommand extends BroadCastCall
    {

        public function HeroArenaCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_2:SArena2v2Team = null;
            var _loc_3:SArena2v2TeamMsg = null;
            var _loc_4:SSeqArenaBasePlayerMsg = null;
            var _loc_5:SArenaBasePlayerMsg = null;
            var _loc_6:SPublicInt = null;
            var _loc_7:SArena2v2Team = null;
            var _loc_8:SArena2v2Team = null;
            Log.debug("I have receive HeroArenaCommand");
            super.call(param1);
            switch(param1.messageHead.command)
            {
                case EPublicCommand._ECmdPublicArenaTeamInfoMy:
                {
                    _loc_2 = param1.messageBase as SArena2v2Team;
                    _loc_7 = Cache.instance.heroArena.myTeamInfo;
                    _loc_8 = _loc_2;
                    HeroArenaUtil.showTipOnTeamChange(_loc_7, _loc_8);
                    Cache.instance.heroArena.myTeamInfo = _loc_2;
                    NetDispatcher.dispatchCmd(ServerCommand.HeroArenaUpdateMyTeamInfo, null);
                    break;
                }
                case EPublicCommand._ECmdPublicArenaTeamInfos:
                {
                    _loc_3 = param1.messageBase as SArena2v2TeamMsg;
                    Cache.instance.heroArena.allTeamInfo = _loc_3.teamInfos;
                    NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetAllTeamInfo, null);
                    break;
                }
                case EPublicCommand._ECmdPublicArenaTeamNoTeamPlayers:
                {
                    _loc_4 = param1.messageBase as SSeqArenaBasePlayerMsg;
                    Cache.instance.heroArena.allSinglePlayers = _loc_4.basePlayers;
                    NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetAllSinglePlayers, null);
                    break;
                }
                case EPublicCommand._ECmdPublicArenaTeamInvite:
                {
                    _loc_2 = param1.messageBase as SArena2v2Team;
                    if (_loc_2)
                    {
                        Cache.instance.heroArena.updateInvateList(_loc_2.captainPlayer, EUpdateType._EUpdateTypeAdd);
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetTeamInvate, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArenaTeamJoin:
                {
                    _loc_5 = param1.messageBase as SArenaBasePlayerMsg;
                    if (_loc_5)
                    {
                        Cache.instance.heroArena.updateApplyList(_loc_5.basePlayer, EUpdateType._EUpdateTypeAdd);
                        NetDispatcher.dispatchCmd(ServerCommand.HeroArenaGetTeamApply, null);
                    }
                    break;
                }
                case EPublicCommand._ECmdPublicArena2LevelInfo:
                {
                    _loc_6 = param1.messageBase as SPublicInt;
                    HeroArenaController.HeroArenaLevel = _loc_6.publicInt;
                    NetDispatcher.dispatchCmd(ServerCommand.HeroArenaUpdateArenaLevel, null);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
